package com.share.user.api.factory;


import com.share.common.core.domain.R;
import com.share.user.api.RemoteUserInfoService;
import com.share.user.api.domain.UpdateUserLogin;
import com.share.user.api.domain.UserInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class RemoteUserInfoFallbackFactory implements FallbackFactory<RemoteUserInfoService> {

    @Override
    public RemoteUserInfoService create(Throwable throwable) {
        log.error("会员管理服务调用失败:{}", throwable.getMessage());
        return new RemoteUserInfoService() {

            @Override
            public R<UserInfo> wxLogin(String code) {
                return R.fail("微信登录失败:" + throwable.getMessage());
            }

            @Override
            public R<Boolean> updateUserLogin(UpdateUserLogin updateUserLogin) {
                return R.fail("更新用户登录失败:" + throwable.getMessage());
            }
        };
    }
}
